/// [Multiples of 3 and 5](https://projecteuler.net/problem=1)
fn main() {
    for num in &[10, 1000] {
        println!("{}以內3或5的所有倍数的总和为{}", num, multiples_of_3_and_5(*num));
    }
}
/// 解法：3的倍数的和 + 5的倍数的和 - 15的倍数的和
fn multiples_of_3_and_5(length: u32) -> u32 {
    sum(3, length) + sum(5, length) - sum(15, length)
}
/// 倍数和
fn sum(base: u32, length: u32) -> u32 {
    let num = (length - 1) / base;
    base * num * (num + 1) / 2
}
